<?php

namespace Smjt\Cart;

use Illuminate\Support\ServiceProvider;

class CartServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(Cart::class,function ($app){
            return new Cart();
        });
        // 注册包中的配置文件，使其可通过 config() 函数访问
        $this->mergeConfigFrom(
            __DIR__.'/config/projectcart.php', 'projectcart'
        );
    }

    public function boot()
    {
        // 发布配置文件到 Laravel 的 config 目录
        $this->publishes([
            __DIR__.'/config/projectcart.php' => config_path('projectcart.php'),
        ], 'config');
    }
}
